package com.zwy.Algorithm.sort;


//选择排序
public class Selection {
    public static void main(String[] args) {
        Selection.Solution solution = new Selection().new Solution();
        int []arr={7,8,9,4,3,1,10,6,5};
         solution.sort(arr);
        System.out.println(arr);
    }
    class Solution {
        public void sort(int []arr) {
            int max=arr[0];
            int index=0;
            int t=0;
            for (int i = 0; i < arr.length; i++) {
                index=0;
                max=arr[0];
                for (int j = 0; j < arr.length-i; j++) {
                    if(arr[j]>max){
                        index=j;
                        max=arr[j];
                    }
                }
               t=arr[arr.length-i-1];
                arr[arr.length-i-1]=arr[index];
                arr[index]=t;
            }

        }

    }
}
